<?

require_once 'common.php';

echo "<p>New Event Here:</p>";
$gc_client = Zend_Gdata_AuthSub::getHttpClient($gc_token);





if(isset($_POST['is_post'] )){
	//Se levantan todos los parametros del form
	$title 		= $_POST['title'];
	$desc 		= $_POST['desc'];
	$where 		= $_POST['where'];
	$startDate = $_POST['startDate'];
	$startTime = $_POST['startTime'];
	$endDate 	= $_POST['endDate'];
	$endTime 	= $_POST['endTime'];
	$tzOffset 	= $_POST['tzOffset'];

	$response = $gc_auth->createEvent($gc_client, $title, $desc, $where, $startDate, $startTime, $endDate, $endTime, $tzOffset);
	    
	
	    

}else{ //se imprime el form
	?>
	<div id=newEventForm>
	
	<form  name="newevent" action="http://apps.facebook.com/bundundu/index.php?tab=2" method="post">
	<table>
		<tr>
			<td> Title:</td> <td> 			<input type="text" name="title"/> </td>
		</tr>
		<tr>
			<td> Description:</td> <td> 	<textarea rows="5" cols="40" name="desc"/></td>
		</tr>	
		<tr>	
			<td> Where:</td> <td>			<input type="text" name="where"/> </td>
		</tr>	
		<tr>
			<td> Starts at:	</td> <td>		<input type="text" name="startDate"/> <input type="text" name="startTime"/> </td>
		</tr>
		<tr>	
			<td> Ends at:</td> <td>			<input type="text" name="endDate"/> <input type="text" name="endTime"/> </td>
		</tr>	
		<tr>
			<td> Time Zone:</td> <td>		<select name="tzOffset">
		
		<?
		$gmt = new gmt();
		$rows = $gmt->getGMT();
		
		foreach($rows as $row){
			echo "<option value=\"". $row['tzoffset'] ."\">" . $row['show_text'] . "</option>";
		}
		
		
		?>
			</td></tr></select></br>	
	</table>				
			<input type="hidden" name="is_post" value="true"/>
			<input type="submit" name="Add!" value="Add!"/><br/>
	
	</form>
	
	
	TODO: seleccionar el calendario. por ahora se inserta en el default!
	
	<br/>
	Example:     'Ring in the new year with Kim and I',
    'Our house', 
    '2006-12-31', '22:00', '2007-01-01', '03:00', '-08' 
	
	</div>
	<?
}
?>